package cn.moningxi.service.impl;

import cn.moningxi.bean.CConsignee;
import cn.moningxi.bean.CustomerInfomation;
import cn.moningxi.mapper.CConsigneeMapper;
import cn.moningxi.service.CConsigneeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class CConsigneeServiceImpl implements CConsigneeService {

    @Autowired
    private CConsigneeMapper cConsigneeMapper;

    @Override
    public List<CConsignee> addrShow(CustomerInfomation onlineUser) {
        return cConsigneeMapper.addShow(onlineUser);
    }

    @Override
    public boolean addaddr(CustomerInfomation onlineUser, CConsignee consignee) {
        consignee.setCustomerId(onlineUser.getCustomerId());
        consignee.setIsDefault("0");
        consignee.setZip("000000");
        consignee.setModifiedTime(LocalDateTime.now());
        return cConsigneeMapper.addaddr(consignee);
    }

    @Override
    public void deladdr(Integer caId) {
        cConsigneeMapper.deladdr(caId);
    }

    @Override
    public void isDefaultAddr(Integer customerAddrId, CustomerInfomation onlineUser) {
        System.out.println(onlineUser.getCustomerId());
        cConsigneeMapper.setAllAddr0(onlineUser);
        cConsigneeMapper.setAddr1(customerAddrId);
    }

    @Override
    public CConsignee queryAddById(Integer caId) {
        return cConsigneeMapper.queryAddById(caId);
    }

    @Override
    public boolean updateAddById(CConsignee consignee) {
        consignee.setModifiedTime(LocalDateTime.now());
        return cConsigneeMapper.updateAddById(consignee);
    }


}
